{include file="public/nheader"}
<style type="text/css">
    .layui-table-cell {
        height: auto;
        line-height: 28px;
        padding: 0 15px;
        position: relative;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: normal;
        box-sizing: border-box;
    }
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <!-- // 默认操作按钮 -->
        <div class="layui-card-header layadmin-card-header-auto ">
            <div class="layui-form">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <div class="layui-input-inline ">
                            <input name="title" class="layui-input" type="text" placeholder="ID|账号|备注" />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline ">
                            <select name="type" lay-search>
                                <option value="">类型</option>
                                <option value="1" {if !empty(input('get.type')) && input('get.type')==1}selected{/if}>普通物料</option>
                                <option value="2" {if !empty(input('get.type')) && input('get.type')==2}selected{/if}>收银机</option>
                                <option value="3" {if !empty(input('get.type')) && input('get.type')==3}selected{/if}>赠品</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline ">
                            <select name="groups" lay-search>
                                <option value="">组别</option>
                                {foreach $grouplist as $k => $v}
                                <option value="{$k}" {if !empty(input('get.groups')) &&
                                    input('get.groups')==$k}selected{/if}>{$v}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <!-- // 默认搜索 -->
                        <button class="layui-btn icon-btn" lay-filter="formSearch" lay-submit>搜索</button>
                        <button class="layui-btn icon-btn" lay-maxmin="true" lay-open="" data-title="添加物料、收银机"
                            data-area="50%,80%" data-url="/goods/goods_add">添加物料、收银机
                        </button>
                        <button class="layui-btn icon-btn" lay-maxmin="true" lay-open="" data-title="添加赠品"
                            data-area="50%,80%" data-url="/goods/goods_add2">添加赠品
                        </button>
                    </div>
                </div>
            </div>
        </div>

        <!-- // 创建数据实例 -->
        <table id="lay-tableList" lay-filter="lay-tableList"></table>
    </div>
</div>
<!-- // 列表工具栏 -->
<script type="text/html" id="tableBar">
    {{#  if(d.type ==1 || d.type == 2){ }}
    <a class="layui-table-text" lay-open data-title="编辑物料、收银机" data-area="50%,80%" data-url="/goods/goods_add?id={{d.id}}" >编辑物料、收银机</a>
    {{#  } }}
    {{#  if(d.type == 3){ }}
    <a class="layui-table-text" lay-open data-title="编辑物料、收银机" data-area="50%,80%" data-url="/goods/goods_add2?id={{d.id}}" >编辑赠品</a>
    {{#  } }}
</script>
{include file="public/nfooter"}
<script>
    layui.use(['admin', 'layer', 'table', 'form'], function () {
        var admin = layui.admin;
        var layer = layui.layer;
        var table = layui.table;        // 表格
        var form = layui.form;
        /*
         * 初始化表格
        */
        var isTable = table.render({
            elem: "#lay-tableList"
            , url: "{:url()}"
            , page: true
            , toolbar: 'true'
            // , defaultToolbar: ["filter","exports","print"]
            , defaultToolbar: [{
                title: '导出excel' //标题
                , layEvent: 'LAYTABLE_EXPORT' //事件名，用于 toolbar 事件中使用
                , icon: 'layui-icon-export' //图标类名
            }, {
                title: '筛选数据' //标题
                , layEvent: 'LAYTABLE_COLS' //事件名，用于 toolbar 事件中使用
                , icon: 'layui-icon-cols' //图标类名
            }]
            , even: true
            , loading: true
            , limits: [10, 20, 40, 60, 80, 100, 150, 200, 300]
            , limit: 10
            , cols: [[
                { field: 'id', align: 'center', sort: true, width: 80, title: 'ID' },
                { field: 'title', width: 160, align: 'center', title: '名称' },
                {
                    field: 'type', align: 'center', width: 100, templet: function (d) {
                        var text = '';
                        if (d.type == 1) {
                            text = '<span class="layui-badge layui-bg-blue">普通物料</span>';
                        }
                        if (d.type == 2) {
                            text = '<span class="layui-badge layui-bg-orange">收银机</span>';
                        }
                        if (d.type == 3) {
                            text = '<span class="layui-badge layui-bg-green">赠品</span>';
                        }
                        return text;
                    }, title: '类型'
                },
                { field: 'type_name', width: 160, align: 'center', title: '组别' },
                { field: 'default_num', width: 160, align: 'center', title: '标准店' },
                { field: 'default_num2', width: 160, align: 'center', title: '精品店' },
                { field: 'default_num3', width: 160, align: 'center', title: '旗舰店' },
                {
                    field: 'sku', width: 160, align: 'center', title: '库存', templet:function(d) {
                        return d.sku + '件';
                    }
                },
                {
                    field: 'total', width: 160, align: 'center', title: '价格', templet:function(d) {
                        return d.total + '元';
                    }
                },
                { field: 'created', width: 200, align: 'center', title: '创建时间' },
                { align: 'center', width: 200, toolbar: '#tableBar', title: '操作' },

            ]]
        })
    })
</script>